package com.jet.core.validation;

import cn.hutool.core.lang.Validator;
import com.jet.core.annotation.Mobile;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Objects;

/**
 * @author dcl
 * @since 2025/1/2 18:31
 */
public class MobileValidator implements ConstraintValidator<Mobile, CharSequence> {

    @Override
    public boolean isValid(CharSequence value, ConstraintValidatorContext context) {
        if (Objects.isNull(value)) {
            return true;
        }
        return Validator.isMobile(value);
    }
}
